function deepClone(targetObj) {
    if (typeof targetObj !== 'object') return targetObj
    let  resObj = targetObj.constructor === Array ? [] : {}
    for (const key in targetObj) {
        if (targetObj[key] && targetObj.hasOwnProperty(key)) {
            if (typeof targetObj[key] === 'object') {
                resObj[key] = targetObj[key].constructor === Array ? [] : {}
                resObj[key] = deepClone(targetObj[key])
            } else {
                resObj[key] = targetObj[key]
            }
        }
    }
    return resObj
}

let obj = {
    a: 1,
    arr: [1, 2, 3],
    o: {
        c: 2,
        d: 's'
    }
}
let newObj = deepClone(obj)
newObj.a = 11
newObj.arr.push(4)
newObj.o.c = 22
console.log(obj, newObj)